<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.User"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>粮油集团办公自动化协作平台</title>
    <meta http-equiv="x-ua-compatible" content="ie=7" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
    <jsp:include page="indexTop.jsp"></jsp:include>        
	<script type='text/javascript' src='<%=basePath%>dwr/interface/FileDocumentGroupBo.js'></script>
	<script type='text/javascript' src='<%=basePath%>dwr/interface/FileDocumentFilePageBo.js'></script>
	<script type='text/javascript' src='<%=basePath%>dwr/interface/FileDocumentFileBo.js'></script>
	<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
	<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
	
	
	<link rel="stylesheet" type="text/css" href="<%=basePath%>ajaxFramework/ext-2.1/resources/css/ext-all.css" />
	<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
   	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all.js"></script>
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/jQuery/jquery.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/common/system/selectusercheck.js"></script>
   	<script type="text/javascript" src="<%=basePath %>fileDocument/js/downUser.js"></script>
    <script type="text/javascript" src="<%=basePath %>js/common/global/validator.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/common/global/pageControl.js"></script>
	<%
		User user = (User)session.getAttribute("user");
		String group_id = (String)request.getAttribute("group_id");
		String user_page = (String)request.getAttribute("user_page");
		String user_id = (String)request.getAttribute("user_id");
		String first = (String)request.getAttribute("first");
		if(first == null || "".equals(first))first = "shi";
		
		String dirName = request.getSession().getServletContext().getRealPath("/");
		dirName = dirName.replace("\\","\\\\");
		ResourceBundle bundle = ResourceBundle.getBundle("com.tjsinfo.tjsoa.fileDocument.properties.systemResource_zh_CN");
		String downUrlFileSize = bundle.getString("downUrlFileSize");
	 %>
	
	<script type="text/javascript">
		var group_id = <%=group_id %>;
		var intpage = <%=user_page %>;
		var first = '<%=first %>';
		var user_id = <%=user_id %>;
		var pagenum = '4';
		var dFileNum = 0;
		var chaxunname = '';
		var chaxunren = '';
		if(intpage == '' || intpage == null){intpage = 1}
		
		function windowonload(){
			document.getElementById("jiazai").style.top = document.body.clientHeight/3;
			document.getElementById("jiazai").style.left = document.body.clientWidth/3;
			document.getElementById("jiazai").style.display = "block";
			document.getElementById("blackdiv").style.display = "block";
			
			document.getElementById("right").style.width = document.body.clientWidth-5;
			document.getElementById("divgroup").style.height = document.body.clientHeight-80;
			document.getElementById("tdindex").style.height = document.body.clientHeight-90;
			document.getElementById("tdindex").style.width = document.body.clientWidth-154;
			document.getElementById("divindex").style.width = document.body.clientWidth-151;
			document.getElementById("divindex").style.height = document.body.clientHeight-50;
			if(first == "shi"){
				<%
					if(user.getPermission().indexOf(",41,")!=-1){
				%>
				FileDocumentGroupBo.getAllGroup(Group);
				huifu();
				<%
					}else{
				%>
				FileDocumentGroupBo.getGroup(<%=user.getUser_id() %>,Group);
				huifu();
				<%
					}
				%>
			}
			initshowuser();
			initselectusercheck();
		}
		
		var groupNum = 0;
		var fu = null;
		function Group(fuzhi){
			var divgroup = document.getElementById("divgroup");
			fu = fuzhi;
			groupNum = fu.length/2;
			var liebiaoGroup = '<table id="grouptable" border="0" width="129px;" cellspacing="0" cellpadding="0">';
			var i = 0;
			for(var a=0;a<fu.length;a=a+2){
				if(fu[a] == group_id){
					if(fu[a+1].length>8){
						liebiaoGroup += '<tr id="group'+i+'" class=\"trGroupColor\" onclick="GroupListUser(\''+fu[a]+'\')" onmouseup=\"ClickGroup('+i+');\"><td width="23px" height="24px" align="center"><img src="<%=basePath%>images/conicon.gif"/></td><td height="24px" valign="middle" style=\"font-weight: bold\"><a id=\"groupA'+i+'\" title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,8)+'</a></td></tr>';
					}else{
						liebiaoGroup += '<tr id="group'+i+'" class=\"trGroupColor\" onclick="GroupListUser(\''+fu[a]+'\')" onmouseup=\"ClickGroup('+i+');\"><td width="23px" height="24px" align="center"><img src="<%=basePath%>images/conicon.gif"/></td><td height="24px" valign="middle" style=\"font-weight: bold\"><a id=\"groupA'+i+'\">'+fu[a+1]+'</a></td></tr>';
					}
				}else{
					if(fu[a+1].length>8){
						liebiaoGroup += '<tr id="group'+i+'" onmouseover=\'this.className=\"trGroupColor\"\' onmouseout=\'this.className=\"\"\' onclick="GroupListUser(\''+fu[a]+'\')" onmouseup=\"ClickGroup('+i+');\"><td width="23px" height="24px" align="center"><img src="<%=basePath%>images/conicon.gif"/></td><td height="24px" valign="middle"><a id=\"groupA'+i+'\" title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,8)+'</a></td></tr>';
					}else{
						liebiaoGroup += '<tr id="group'+i+'" onmouseover=\'this.className=\"trGroupColor\"\' onmouseout=\'this.className=\"\"\' onclick="GroupListUser(\''+fu[a]+'\')" onmouseup=\"ClickGroup('+i+');\"><td width="23px" height="24px" align="center"><img src="<%=basePath%>images/conicon.gif"/></td><td height="24px" valign="middle"><a id=\"groupA'+i+'\">'+fu[a+1]+'</a></td></tr>';
					}
				}
				i++;
			}
			if(fu.length>30){
				document.getElementById("zushang").style.display = "block";
				document.getElementById("zuxia").style.display = "block";
			document.getElementById("divgroup").style.height = document.body.clientHeight-110;
			}else{
				document.getElementById("zushang").style.display = "none";
				document.getElementById("zuxia").style.display = "none";
			}
			liebiaoGroup += '</table>';
			divgroup.innerHTML= liebiaoGroup;
		}
        
        var groupA = -1;
        function ClickGroup(i){
			if(groupA!=-1)
			document.getElementById("group"+groupA).onmouseout = function(){this.className=''};
        	for(var a = 0 ; a<groupNum;a++ ){
				var b = document.getElementById("group"+a);
				var c = document.getElementById("groupA"+a);
				if(a == i){
					b.className="trGroupColor";
					c.style.fontWeight="bold";
					b.onmouseout = null;
					groupA = a;
				}else{
					c.style.fontWeight="100";
					b.className='';
				}
			}
        }
		function init(page){
			intpage=page;
			FileDocumentFilePageBo.getGotoPage(group_id,intpage,pagenum,<%=user.getUser_id() %>,chaxunname,chaxunren,ListUser);
		}
		
		function chaxunname1(){
			if(group_id=='' || group_id==null){
				alert('请选择文件夹！');
			}else{
				chaxunren = '';
				Ext.MessageBox.prompt('输入框', '请输入文件名称！', function(btn, text) {
					if(btn=='ok'){
						chaxunname = '';
				        if(text!='' && text!=null){
				        	chaxunname = text;
							FileDocumentFilePageBo.getGotoPage(group_id,1,pagenum,<%=user.getUser_id() %>,text,'',ListUser);
						}else{
							FileDocumentFilePageBo.getGotoPage(group_id,1,pagenum,<%=user.getUser_id() %>,'','',ListUser);
						}
					}
			    });
		    }
		}
		
		function chaxunren1(){
			if(group_id=='' || group_id==null){
				alert('请选择文件夹！');
			}else{
				chaxunname = '';
				Ext.MessageBox.prompt('输入框', '请输入发布人！', function(btn, text) {
					if(btn=='ok'){
						chaxunren = '';
				        if(text!='' && text!=null){
				        	chaxunren = text;
							FileDocumentFilePageBo.getGotoPage(group_id,1,pagenum,<%=user.getUser_id() %>,'',text,ListUser);
						}else{
							FileDocumentFilePageBo.getGotoPage(group_id,1,pagenum,<%=user.getUser_id() %>,'','',ListUser);
						}
					}
			    });
		    }
		}
		
		function ListUser(addressListUser){
			var divindex = document.getElementById("divindex");
			var liebiaoUser = '<table class="p_06" width=\"100%\" border=\"0\" cellspacing=\"0\"><tr><th width=\"4%\" style="text-align: center;">全选</th><th width=\"22%\" style="text-align: center;">文档名称</th><th width=\"8%\" style="text-align: center;">发布人</th><th width=\"15%\" style="text-align: center;">发布时间</th><th width=\"10%\" style="text-align: center;">大小</th><th width=\"5%\" style="text-align: center;">摘要</th><th width=\"10%\" style="text-align: center;">下载/重命名</th></tr>';
			if(addressListUser.length != '0'){
			dFileNum = addressListUser.length;
			liebiaoUser = '<form name=checkboxform><table class="p_06" width=\"100%\" border=\"0\" cellspacing=\"0\"><tr><th width=\"4%\" style="text-align: center;"><a href="javaScript:switchAll('+addressListUser.length+')">全选</a></th><th width=\"22%\" style="text-align: center;">文档名称</th><th width=\"10%\" style="text-align: center;">发布人</th><th width=\"15%\" style="text-align: center;">发布时间</th><th width=\"10%\" style="text-align: center;">大小</th><th width=\"5%\" style="text-align: center;">摘要</th><th width=\"10%\" style="text-align: center;">下载/重命名</th></tr>';
			for(var i=0;i<addressListUser.length;i++){
				var id = addressListUser[i].id;
				var datetime = addressListUser[i].datetime;
				var expressUser = addressListUser[i].expressUser;if(expressUser==null || expressUser == '')expressUser='&nbsp;'; else expressUser = retrunString(expressUser,11,11);
				var expressUser1 = addressListUser[i].expressUser;if(expressUser1==null || expressUser1 == '')expressUser1='';
				var remark = addressListUser[i].docket;
				if(remark==null || remark==''){
					remark='无备注';}else{ remark=remark.replace(/'/g,"\\'");}
				var remark1 = '';if(remark=='无备注')remark1='无'; else remark1='详细';
				var fileSize = addressListUser[i].fileSize;
				if(fileSize>1048576)fileSize = (fileSize/1048576).toFixed(2)+"M"; else fileSize = (fileSize/1024).toFixed(1)+"KB";
				addressListUser[i].fileName = addressListUser[i].fileName.replace(/'/g,'＇');
				var name = retrunString(addressListUser[i].fileName);
				var name1 = addressListUser[i].fileName;
				if(user_id != null && user_id != '' && user_id == addressListUser[i].id){
					liebiaoUser += '<tr id="beizhutrid'+i+'" class=\"trBgColor\"><td><input type="checkbox" name="dFile'+i+'" id='+id+'/></td><td><a title=\"'+name1+'\" href="javaScript:downloadfile(\''+id+'\',\''+addressListUser[i].fileName+'\','+addressListUser[i].fileSize+');">'+name+'</a></td><td><a title=\"'+expressUser1+'\">'+expressUser+'</td><td><a title=\"'+datetime+'\">'+datetime+'</a></td><td><a title=\"'+fileSize+'\">'+fileSize+'</a></td><td id="beizhuid'+i+'"><a onclick="javascript:beizhuxian(\''+remark+'\','+i+');">'+remark1+'</a></td><td><a href="javaScript:downloadfile(\''+id+'\',\''+addressListUser[i].fileName+'\','+addressListUser[i].fileSize+');">下载</a><%if(user.getPermission().indexOf(",41,")!=-1){ %>\|<a href="javaScript:updateFileName('+id+');">重命名</a><%}%></td></tr>';
				}else{
					liebiaoUser += '<tr id="beizhutrid'+i+'" onmouseover=\'this.className=\"trBgColor\"\' onmouseout=\'this.className=\"\"\'><td><input type="checkbox" name="dFile'+i+'" id='+id+'/></td>';
					liebiaoUser += '<td><div id="fNamediv'+i+'"><a title=\"'+name1+'\" href="javaScript:downloadfile(\''+id+'\',\''+addressListUser[i].fileName+'\','+addressListUser[i].fileSize+');">'+name+'</a></div>';
					liebiaoUser += '<div id="fNamedivF'+i+'" style="display:none"><input id="rlinput'+i+'" size="28" type="text" style="text-align: center"></td></div>';
					liebiaoUser += '<td><a title=\"'+expressUser1+'\">'+expressUser+'</a></td><td><a title=\"'+datetime+'\">'+datetime+'</a></td><td><a title=\"'+fileSize+'\">'+fileSize+'</a></td>';
					liebiaoUser += '<td id="beizhuid'+i+'"><a onclick="javascript:beizhuxian(\''+remark+'\','+i+');">'+remark1+'</a></td>';
					liebiaoUser += '<td><div id="chongdiv'+i+'"><a href="javaScript:downloadfile(\''+id+'\',\''+addressListUser[i].fileName+'\','+addressListUser[i].fileSize+')">下载</a><%if(user.getPermission().indexOf(",41,")!=-1){ %><a>\|</a><a href="javaScript:chongming('+i+',\''+name1+'\');">重命名</a><%} %></div>';
					liebiaoUser += '<div id="chongdivF'+i+'" style="display:none"><a href="javaScript:chongmingTrue('+i+',\''+id+'\',\''+addressListUser[i].fileName+'\','+addressListUser[i].fileSize+');" style="color: red;" >确定</a>&nbsp;&nbsp;<a href="javaScript:xiaoshichong('+i+');" style="color: red;" >取消</a></div></td></tr>';
				}
			}
			
			liebiaoUser += '<tr align=\"center\"><td colspan="8"><div class="pages" id="page">';
			FileDocumentFilePageBo.getPagecount({
			callback:function(pagecount) {
				//下拉框

			if(intpage == '' || intpage == null){intpage = 1}
			if(first == 'delete' && intpage == pagecount+1){
				intpage = pagecount;
				first = null;
			}
             var select="<select name=\"sel\">";
             for(var i=0;i<pagecount;i++){
                if((i+1)==intpage)
              select+="<option value=\""+(i+1)+"\" selected>"+(i+1)+"</option>";
              else
              select+="<option value=\""+(i+1)+"\">"+(i+1)+"</option>";              
             }	
             select+="</select>";
             
             //链接条

             var linkstr="";
             if(intpage>pagecount)intpage=pagecount;
             
             if(intpage>1){
                linkstr+="&nbsp;&nbsp;<a href=\"javascript:init("+(Number(intpage)-1)+")\">上一页</a>";
             }
             if(intpage<pagecount){
                linkstr+="&nbsp;&nbsp;<a href=\"javascript:init("+(Number(intpage)+1)+")\">下一页</a>";
             }
             
             //按钮
             var btn="<input type='button' value='转到' onclick='init(sel.value)'/>";
             
             //  第XXX页/共XXX页

             var mix="<a>共"+pagecount+"页,当前为第"+intpage+"页</a>";
             
             divindex.innerHTML=liebiaoUser+mix+linkstr+'		'+select+'			'+btn;
             divindex.innerHTML+="</div></td></tr></table></form>";
			}
		});
			document.getElementById("jiazai").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
			huifu();
			first='no';
		}else{
			if(first == 'delete' && addressListUser.length != '0'){
				FileDocumentFilePageBo.getLastPage(group_id,pagenum,<%=user.getUser_id() %>,chaxunname,chaxunren,ListUser);
			}
			liebiaoUser += '</table></form>';
			document.getElementById("jiazai").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
			huifu();
		}
			divindex.innerHTML= liebiaoUser;
		}
		
		function switchAll(i) {
			var box = eval("document.checkboxform.dFile0");
			var bl = false;
			if(box.checked == false){
				bl = true;
			}
			for (var j = 0; j <= i-1; j++) {
				box = eval("document.checkboxform.dFile" + j); 
				box.checked = bl;
			}
		}
		
		function chongming(i,fileName){
			document.getElementById('chongdiv'+i+'').style.display = "none";
			document.getElementById('chongdivF'+i+'').style.display = "block";
			document.getElementById('fNamediv'+i+'').style.display = "none";
			document.getElementById('fNamedivF'+i+'').style.display = "block";
			document.getElementById('rlinput'+i+'').value = fileName.split(".")[0];
		}
		
		function xiaoshichong(i){
			document.getElementById('chongdiv'+i+'').style.display = "block";
			document.getElementById('chongdivF'+i+'').style.display = "none";
			document.getElementById('fNamediv'+i+'').style.display = "block";
			document.getElementById('fNamedivF'+i+'').style.display = "none";
		}
		
		function chongmingTrue(i,id,fileName,fileSize){
			var newName = document.getElementById('rlinput'+i+'').value;
			fileName = fileName.replace(fileName.split('.')[0],newName);
			FileDocumentFileBo.updateFileName(id,fileName,'<%=dirName %>',{
				callback:function(str) {
					if(str=='ok'){
						var name = retrunString(fileName,12,15);
						var name1 = newName;
						document.getElementById('fNamediv'+i+'').innerHTML = '<a title=\"'+name1+'\" href="javaScript:downloadfile(\''+id+'\',\''+newName+'\','+fileSize+');">'+name+'</a>';
						document.getElementById('chongdiv'+i+'').innerHTML = '<a href="javaScript:downloadfile(\''+id+'\',\''+newName+'\','+fileSize+')">下载</a><a>\|</a><a href="javaScript:chongming('+i+',\''+newName+'\');">重命名</a>';
						xiaoshichong(i);
					}else{
						Ext.MessageBox.alert(str);
					}
				}
			});
		}
		
		function downloadfile(id,filename,fileSize){
			document.getElementById("blackdiv").style.display = "block";
			document.getElementById("fileDownloadDiv").style.top = document.body.clientHeight/4;
			document.getElementById("fileDownloadDiv").style.left = document.body.clientWidth/5;
			document.getElementById("fileDownloadDiv").style.display = "block";
			document.getElementById("xiazaidiv").innerHTML = '您现在要下载的文件是:'+filename;
			var path = '<%=basePath %>upload/fileDocument/';
			var downUrlFileSize = <%=downUrlFileSize %>;
			document.getElementById("filedown").href='<%=basePath %>tjsinfo/tjsoa/fileDocument/ioAction.do?id='+id+'';
		}

		function xiaoshiFileDownloadDiv(){
			document.getElementById("fileDownloadDiv").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
		}
		
		function getGroup_id(Group_id){
			group_id = Group_id;
			FileDocumentGroupBo.getGroup(<%=user.getUser_id() %>,Group);
		}
		function GroupListUser(groupid){
			
			selectuserrolse(groupid)
			group_id = groupid;
			user_id = '';
			intpage = 1;
			FileDocumentFilePageBo.getGotoPage(groupid,1,pagenum,<%=user.getUser_id() %>,chaxunname,chaxunren,ListUser);
		}
		
		function xianshigroup(){
			var Objxy=getXY(document.getElementById("groupbianji"));
			document.getElementById("groupcaozuo").style.top = Objxy.y+26;
			document.getElementById("groupcaozuo").style.display = "block";
		}
		
		function xiaoshigroup(){
			if(!groupcaozuo.contains(window.event.srcElement) && !groupbianji.contains(window.event.srcElement)){
				document.getElementById("groupcaozuo").style.display = "none";
			}
		}
		
		function xiaoshigroup1(){
			if(groupcaozuo.contains(window.event.srcElement)){
				document.getElementById("groupcaozuo").style.display = "none";
			}
		}
		
		function getXY(Obj) {
			var sumTop = 0, sumLeft = 0;
			while(Obj != document.body){
			sumLeft += Obj.offsetLeft;sumTop += Obj.offsetTop;Obj = Obj.offsetParent;
			} 
			return {x:sumLeft, y:sumTop};
		} 
		
		function xianshiInsertGroup(){
			document.getElementById("insertGroup").style.top = document.body.clientHeight/4;
			document.getElementById("insertGroup").style.left = document.body.clientWidth/5;
			document.getElementById("insertGroupName").value = '';
			document.getElementById("insertGroup").style.display = "block";
			document.getElementById("blackdiv").style.display = "block";
		}
		
		function xiaoshiInsertGroup(){
			document.getElementById("insertGroup").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
		}
		
		function insertGroup(){
			var groupName = document.getElementById("insertGroupName").value;
			var downuserid = document.getElementById("downuserid").value;
			if(downuserid == '' || downuserid == null){
				Ext.MessageBox.confirm('提示框', '您没有设置下载此种类文档的系统用户，是否继续？', function(btn){
					if(btn=='yes'){
						document.getElementById("downuserid").value = '';
						var i = yanzhenggroupName(groupName);
						if(i != 'error'){
							FileDocumentGroupBo.insertGroup(groupName,downuserid,returnGroupCaoZuo);
							xiaoshiInsertGroup();
							Ext.MessageBox.alert('提示框','<nobr>新增成功</nobr>');
						}else{
							document.getElementById("insertGroupName").value = '';
						}
					}
				});
			}else{
				document.getElementById("downuserid").value = '';
				var i = yanzhenggroupName(groupName);
				if(i != 'error'){
					document.getElementById("insertGroupName").value = '';
					document.getElementById("downuserid").value = '';
					document.getElementById("downusername").value = '';
					FileDocumentGroupBo.insertGroup(groupName,downuserid,returnGroupCaoZuo);
					xiaoshiInsertGroup();
					Ext.MessageBox.alert('提示框','<nobr>新增成功</nobr>');
				}else{
					document.getElementById("insertGroupName").value = '';
					document.getElementById("downuserid").value = '';
					document.getElementById("downusername").value = '';
				}
			}
		}
		
		var re_groupname = /^[\w\u4E00-\u9FA5]{1,25}$/;
		function yanzhenggroupName(groupName){
			if(groupName == '' || groupName == null){
				Ext.MessageBox.alert('提示框','<nobr>文件夹名不能为空</nobr>');
				return 'error';
			}
			if(groupName == '我的接收文件夹'){
				Ext.MessageBox.alert('提示框','<nobr>文件夹名\"'+groupName+'\"是系统保留的联系人组名，不允许使用该组名</nobr>');
				return 'error';
			}
			for(var a=0;a<fu.length;a=a+2){
				if(fu[a+1] == groupName){
					Ext.MessageBox.alert('提示框','<nobr>文件夹名已经存在</nobr>');
					return 'error';
				}
			}
			if(groupName.length>25){  //中文，字母，数字，下划线
				Ext.MessageBox.alert('提示框','<nobr>新建文件夹名不能超过25个字</nobr>');
				return 'error';
			}
			if(!re_groupname.test(groupName)){  //中文，字母，数字，下划线
				Ext.MessageBox.alert('提示框','<nobr>新建文件夹名含有非法字符</nobr>');
				return 'error';
			}
		}
		
		function returnGroupCaoZuo(str){
			if(str == 'ok'){
				FileDocumentGroupBo.getAllGroup(Group);
			}
		}
		
		function xianshiUpdateGroup(){
			document.getElementById("updateGroupIndexDiv").style.top = document.body.clientHeight/6;
			document.getElementById("updateGroupIndexDiv").style.left = document.body.clientWidth/8;
			document.getElementById("blackdiv").style.display = "block";
			document.getElementById("updateGroupIndexDiv").style.display = "block";
			updateGroupName();
		}
		
		function xiaoshiUpdateGroup(){
			document.getElementById("updateGroupIndexDiv").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
			document.getElementById("newGroupName").value = '';
		}
		
		function updateGroupName(){
			var updateGroup = '<table width="100%" class="researchtab"><tr>';
			var i = 0;
			for(var a=0;a<fu.length;a=a+2){
				if(fu[a+1].length>=5){
					updateGroup += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'" onclick="newGroupName(this)"/><a title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,6)+'</a></td>';
				}else{
					updateGroup += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'" onclick="newGroupName(this)"/>'+fu[a+1]+'</td>';
				}
				i++;
				if(i%3 == 0){
					updateGroup += '</tr><tr>';
				}else if(a == fu.length-1){
					updateGroup += '</tr>';
				}
			}
			var updateGroupDiv = document.getElementById("updateGroupDiv");
			updateGroupDiv.innerHTML = updateGroup;
		}
		
		function updateGroup(){
			var a = 0;
			var id = 0;
			if(document.all('groupidradio').length != null && document.all('groupidradio').length > 0){
				for(i=0;i<document.all('groupidradio').length;i++){
					if(document.all('groupidradio')[i].checked){
						a = 1;
						id = document.all('groupidradio')[i].value;
					}
				}
			}else{
				if(document.getElementById('groupidradio').checked){
					a = 1;
					id = document.getElementById('groupidradio').value;
				}
			}
			if(a == 0){Ext.MessageBox.alert('提示框','<nobr>请选择文件夹</nobr>');return;}
			var groupName = document.getElementById("newGroupName").value;
			var i = yanzhenggroupName(groupName);
			if(i != 'error'){
				FileDocumentGroupBo.updateGroup(id,groupName,returnGroupCaoZuo);
				xiaoshiUpdateGroup();
				Ext.MessageBox.alert('提示框','<nobr>修改成功</nobr>');
			}
		}
		
		function newGroupName(str){
			document.getElementById('newGroupName').value = str.alt;
		}
		
		function xianshiDeleteGroup(){
			document.getElementById("deleteGroupIndexDiv").style.top = document.body.clientHeight/5;
			document.getElementById("deleteGroupIndexDiv").style.left = document.body.clientWidth/6;
			document.getElementById("blackdiv").style.display = "block";
			document.getElementById("deleteGroupIndexDiv").style.display = "block";
			deleteGroupName();
		}
		
		function xiaoshiDeleteGroup(){
			document.getElementById("deleteGroupIndexDiv").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
		}
		
		function deleteGroupName(){
			var deleteGroup = '<table width="100%" class="researchtab"><tr>';
			var i = 0;
			for(var a=0;a<fu.length;a=a+2){
				if(fu[a+1].length>=5){
					deleteGroup += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'"/><a title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,6)+'</a></td>';
				}else{
					deleteGroup += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'"/>'+fu[a+1]+'</td>';
				}
				i++;
				if(i%3 == 0){
					deleteGroup += '</tr><tr>';
				}else if(a == fu.length-1){
					deleteGroup += '</tr>';
				}
			}
			var deleteGroupDiv = document.getElementById("deleteGroupDiv");
			deleteGroupDiv.innerHTML = deleteGroup;
		}
		
		var deleteGroupId = '';
		function deleteGroup(){
			var a = 0;
			var id = 0;
			for(i=0;i<document.all('groupidradio').length;i++){
				if(document.all('groupidradio')[i].checked){
					a = 1;
					id = document.all('groupidradio')[i].value;
					deleteGroupId = id;
					if(i == groupA-1){groupA = 0}
				}
			}
			if(document.getElementById('groupidradio').checked){
				a = 1;
				id = document.getElementById('groupidradio').value;
				deleteGroupId = id;
			}
			if(a == 0){Ext.MessageBox.alert('提示框','<nobr>请选择文件夹</nobr>');return;}
			shaodeng();
			FileDocumentGroupBo.FirstDeleteGroup(id,'<%=dirName %>',firstDeleteGroup);
			xiaoshiDeleteGroup();
			Ext.MessageBox.alert('提示框','<nobr>删除成功</nobr>');
		}
		
		function firstDeleteGroup(str){
			if(str == "haveUser"){
				Ext.MessageBox.alert('提示框','<nobr>此文件夹下含有文档，请清空后才能删除</nobr>');
				huifu();
			}else{
				returnDeleteGroupCaoZuo('ok');
			}
		}
		
		function deleteListUser(){
			var a = false;
			var ids = '';
			for (var j = 0; j <= dFileNum-1; j++) {
				box = eval("document.checkboxform.dFile" + j);
				if(box.checked == true){
					a = true;
					ids += box.id.substring(0,box.id.length-1)+",";
				}
			}
			if(a){
				Ext.MessageBox.confirm('提示框', '您是否确认删除文件？', function(btn){
					if(btn=='yes'){
						//shaodeng();
						FileDocumentFileBo.deleteFile(ids,'<%=dirName %>',{
							callback:function(str) {
								if(str=='ok'){
									Ext.MessageBox.alert('提示框','<nobr>删除成功</nobr>');
									first='delete';
									FileDocumentFilePageBo.getGotoPage(group_id,intpage,pagenum,<%=user.getUser_id() %>,chaxunname,chaxunren,ListUser);
								}else{
									huifu();
								}
							}
						});
					}
				});
			}else{
				Ext.MessageBox.alert('提示框','<nobr>请选择删除文件</nobr>');
			}
		}
		function returnDeleteFile(str){
			if(str == 'ok'){
				Ext.MessageBox.alert('提示框','<nobr>删除成功</nobr>');
				first='delete';
				FileDocumentFilePageBo.getGotoPage(group_id,intpage,pagenum,<%=user.getUser_id() %>,chaxunname,chaxunren,ListUser);
			}else{
				huifu();
			}
		}
		
		function returnDeleteGroupCaoZuo(){
			first = 'shi';
			FileDocumentGroupBo.getAllGroup(Group);
		}
		function shaodeng(){
			document.getElementById("shaodeng").style.top = document.body.clientHeight/3;
			document.getElementById("shaodeng").style.left = document.body.clientWidth/3;
			document.getElementById("shaodeng").style.display = "block";
			document.getElementById("blackdiv").style.display = "block";
		}
		
		function huifu(){
			document.getElementById("shaodeng").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
			document.getElementById("jiazai").style.display = "none";
		}
		function showdownuser(){
			if(group_id==null || group_id==''){
				Ext.MessageBox.alert('提示框','<nobr>请选择要设置的文件夹</nobr>');
			}else{
				userrolsewinshow();
			}
		}
	</script>
	<%-- 向上向下滑动--%>
	 <script type="text/JavaScript">
var sh;
preLeft=0; currentLeft=0; stopscroll=false; getlimit=0;preTop=0; currentTop=0;
function scrollLeft()
{
	var marquees = document.getElementById("divgroup");
	if(stopscroll==true) return;
	preLeft=marquees.scrollTop;
	marquees.scrollTop+=2;
	if(preLeft==marquees.scrollTop)
	{
		//marquees.scrollLeft=templayer.offsetWidth-marqueesWidth+1;
	}
}

function scrollRight()
{
	var marquees = document.getElementById("divgroup");
	if(stopscroll==true) return;

	preLeft=marquees.scrollTop;
	marquees.scrollTop-=2;
	if(preLeft==marquees.scrollTop)
	{
		if(!getlimit)
		{
			marquees.scrollLeft=templayer.offsetWidth*2;
			getlimit=marquees.scrollLeft;
		}
		marquees.scrollLeft-=1;
	}
}

function Left()
{
	stopscroll = false;
	sh = setInterval("scrollLeft()",30);
}

function Right()
{
	stopscroll = false;
	sh = setInterval("scrollRight()",30);
}

function StopScroll()
{
	stopscroll = true;
	clearInterval( sh );
}
</script>
<%-- 宽窄屏截字符 --%>
<script type="text/javascript">
	function retrunString(str,k,z){
		if(screen.width <= 1024){
			str = str.substring(0,z);
		}else{
			str = str.substring(0,k);
		}
		return str;
	}
	
	function ifsubmit(str,k,z){
		if(screen.width <= 1024){
			if(str.length > z)return false; else return true;
		}else{
			if(str.length > k)return false; else return true;
		}
	}
</script>
  </head>
  <body>
  	<input type="hidden" name="<%=basePath %>" id="basePath"/>
	<input type="hidden" name="" id="node"/>
    <div id="right" style="z-index: 19;">
      	<div id="menu" style="padding-top:4px;"><a id="windowOpen" style="display: none;">&nbsp;</a></div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-right:#CCCCCC solid 1px;">
          <tr>
            <td width="132px;" valign="top" align="left" height="100%">
              <div class="conren" style="height: 450px">
                <div class="h"><table width="132px;" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="20%" align="center"><img src="<%=basePath%>images/zuicon.png"/></td>
                        <td align="left">文件夹<br/></td>
                      </tr>
                    </table>
                </div>
                <div id="zushang" class="zuxia" onmouseout=StopScroll() onmouseover=Right() style='cursor:pointer;display: none;'></div>
                  <table width="132px;" height="390px" border="0" cellspacing="0" cellpadding="0" id="grouptable">
                    <tr height="80%" valign="top">
                      <td>
                      	<div id="divgroup"></div>
                      	<DIV id=templayer style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px"></DIV>
                      </td>
                    </tr>
                </table>
                <div id="zuxia" class="zushang" onmouseout=StopScroll() onmouseover=Left() style='cursor:pointer;display: none;'></div>
              </div>
            </td>
            <td valign="top" id="tdindex">
               <div id="divindex" class="contab" style="height: 98%;width: 99%">
              </div>
            </td>
          </tr>
      </table>
</div>
<%--新增种类层 --%>
<div class="insertGroup" id="insertGroup">
	<table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td height="24" align="left" background="<%=basePath%>images/small_07.gif">
                 <table width="99%" border="0" cellspacing="0" cellpadding="0">
				     <tr>
				         <td width="6%" align="center" style="padding-top:3px;"><img src="images/icon_06.gif" /></td>
				         <td width="88%" style="color:#FFFFFF; font-weight:bold;padding-top:3px">新建文件夹</td>
				         <td width="6%" valign="bottom">
							<div class="cha">
								<img src="<%=basePath%>images/cha.gif"
									onclick="javaScript:xiaoshiInsertGroup();"
											style="cursor: hand" />
							</div>
						</td>
				     </tr>
				</table>
                 </td>
               </tr>
                <tr>
                 <td height="109" class="zz">
                     <table width="90%" height="80%" border="0" cellspacing="0" cellpadding="0" class="researchtab">
                      <tr>
                        <td width="10%">&nbsp;&nbsp;</td>
                        <td width="20%" align="center">新文件夹名称：</td>
                        <td width="70%" align="left"><input name="insertGroupName" type="text" size="40" class="textinput"/><br/>
						<input type="hidden" name="downuserid" id="downuserid" />
                        </td>
                      </tr>
                      <tr>
	                      <td width="10%">&nbsp;&nbsp;</td>
	                      <td width="20%" align="center">设置下载用户：</td>
	                      <td width="70%" align="left"><input name="downusername" id="downusername" type="text" size="20" class="textinput" readonly="readonly"/><a href="javascript:selectusercheckwinshow('downuserid','downusername','node')"><img src="<%=basePath%>images/icon100.gif" /></a><br/>
	                     
                      </tr>
                       <tr>
                        <td colspan="3" style="border-top:1px #CFCFD1 solid" align="center">
                        <a href="javaScript:insertGroup();"><img src="<%=basePath%>images/baocun.gif" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javaScript:xiaoshiInsertGroup();"><img src="<%=basePath%>images/qx.gif" /></a>
                        </td>
                       </tr>
                    </table>
                 </td>
               </tr>
             </table>
</div>
<jsp:include page="indexDown.jsp"></jsp:include>
		<script type=text/javascript>
		function getXY(Obj) {
			var sumTop = 0, sumLeft = 0;
			while(Obj != document.body){
			sumLeft += Obj.offsetLeft;sumTop += Obj.offsetTop;Obj = Obj.offsetParent;
			} 
			return {x:sumLeft, y:sumTop};
		}
		
		function beizhuxian(remark,i){
			var pageselect = document.getElementById('page'); 
	 		pageselect.style.display = "none";
			var windowdiv = document.getElementById("windowdiv");
			if(windowdiv.style.display != 'none') {
				beizhuguan('true');
			}
			if(windowdiv.style.display == 'none') {
				document.getElementById("beizhutrid"+i+"").className="trBgColor";
				document.getElementById("beizhutrid"+i+"").onmouseout = '';
				var beizhudiv = document.getElementById("beizhuid"+i+"");
				var Objxy=getXY(beizhudiv);
				
				var topzhu = windowdiv.style.top;
				var h = document.body.offsetHeight;
				if(h-Objxy.y>200){
					windowdiv.style.top = Objxy.y+23;
				}else{
					windowdiv.style.top = Objxy.y-200;
				}
				windowdiv.style.left = Objxy.x-500;
				document.getElementById('remarkdiv').innerHTML=remark;
				document.getElementById('beizhuid').value=i;
				windowdiv.style.display = 'block';
			}
		}
		
		function beizhuguan(bl){
			if(bl==null){
				var pageselect = document.getElementById('page');
		 		pageselect.style.display = "block";
	 		}
			var i = document.getElementById('beizhuid').value;
			
			var beizhudiv = document.getElementById("beizhuid"+i+"");
			var Objxy=getXY(beizhudiv);
			
			var b = document.getElementById('beizhutrid'+i+'');
			b.onmouseout=function(){this.className='';};
			document.getElementById("beizhutrid"+i+"").className=null;
			var windowOpendiv = document.getElementById("windowdiv");
			windowdiv.style.display = 'none';
		}
</script>
	
	
  </body>
</html>
